﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Estore.ViewModels.LogonModel>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Logon</title>
     <script type="text/javascript" src="../../Scripts/jquery-1.2.2.pack.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-1.2.3.min.js"></script>
      
</head>
<body>

     <div>
     <script type="text/javascript" src="../../Scripts/MicrosoftAjax.js"></script>
      <script type="text/javascript" src="../../Scripts/MicrosoftMvcValidation.js"></script>
      <% Html.EnableClientValidation(); %>
     <form method="post" action="">
    
    <h2>User Login</h2>
    
      <div>User name</div>
      <div> <%:Html.TextBoxFor(m=>m.User_name) %></div>
      <div> <%: Html.ValidationMessageFor(m => m.User_name) %>
      </td></div>
      <div>Pass word</div>
      <div> <%:Html.PasswordFor(m=>m.Pass_word) %></div>
      <div><input type="submit" onclick="reload();" value="login" id= "btn_login" /></div>
      </form>
    </div>
    <%= ViewData["test"] as string %>
       <a href="../Account/Register">Register</a>
  <script type="text/javascript">
      function reload() {
    
          if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
              xmlhttp = new XMLHttpRequest();
             
          }
          else {// code for IE6, IE5
              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          xmlhttp.onreadystatechange = function () {
                    alert(xmlhttp.responseText);
            
                  if (xmlhttp.responseText == -1) {
                      alert("Có lỗi trong quá trình edit");
                      alert(xmlhttp.responseText);
                  }

                  if (xmlhttp.responseText == "1") {

                      alert("thanh cong");
                      window.parent.$.prettyPhoto.close();
                      window.top.location.reload();
                  }

              
          };
         
          var url = "../Account/Logon";
          xmlhttp.open("POST", url, true);
          xmlhttp.send();
          return false;
                 // window.parent.$.prettyPhoto.close();
                //   window.top.location.reload();
}
      
  </script>
  <%: Html.ValidationSummary(true) %>
</body>

</html>
